/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.config.javabeans;

import java.awt.Color;


/** This class conveys a color for orgchart and trombinoscope. */
public class JBColor implements java.io.Serializable
{
    /** red component. */
    private String red;

    /** green component. */
    private String green;

    /** blue component. */
    private String blue;

    /**
     * set the red component.
     * @param value the red value (0..255)
     */
    public void setRed(String value)
    {
        this.red = value;
    }

    /**
     * set the green component.
     * @param value the green value (0..255)
     */
    public void setGreen(String value)
    {
        this.green = value;
    }

    /**
     * set the blue component.
     * @param value the blue value (0..255)
     */
    public void setBlue(String value)
    {
        this.blue = value;
    }

    /**
     * get the color.
     * @return the color generated from components.
     */
    public Color getColor()
    {
        if ((red != null) && (green != null) && (blue != null))
        {
            try
            {
                int ired = Integer.parseInt(red);
                int igreen = Integer.parseInt(green);
                int iblue = Integer.parseInt(blue);

                return new Color(ired, igreen, iblue);
            }
            catch (Exception ex)
            {
                return Color.lightGray;
            }
        }
        else
        {
            return Color.lightGray;
        }
    }
}
